/* global fetch */

//import {delay} from 'redux-saga/effects'
import {all, call, put, take, takeEvery} from 'redux-saga/effects'


import {loadDataSuccess} from './action'


// function * runClockSaga () {
//   yield take(actionTypes.START_CLOCK)
//   while (true) {
//     yield put(tickClock(false))
//     yield delay(1000)
//   }
// }

// function * loadDataSaga () {
//   try {
//     const res = yield fetch('https://jsonplaceholder.typicode.com/users')
//     const data = yield res.json() 
//     yield put(loadDataSuccess(data))
//   } catch (err) {
//     yield put(failure(err))
//   }
// }
export const effects = {
  // 获取话题列表
  *fetchInfor({ payload }) {
    const res = payload
    yield put(loadDataSuccess(res));
  },
  
}

function * rootSaga () {
  // yield all([
  //   call(runClockSaga),
  //   takeLatest(actionTypes.LOAD_DATA, loadDataSaga)
  // ])
  for(let i in effects){
    yield takeEvery(i, effects[i]);
  }
}

export default rootSaga